package com.jxm.security.handler;

import com.jxm.security.common.R;
import com.jxm.security.common.ResponseUtil;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: jxm
 * @Description: 自定义授权处理器
 * @Date: 2022/5/26 10:26
 * @Version: 1.0
 */
@Component
public class MyAccessDeniedHandlerImpl implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
//        ResponseUtil.out(response, R.error().message("权限不足"));
        ResponseUtil.notAuthorized(response);
    }
}
